package com.wushijia.java8.time;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormatDemo {

  private final static DateFormat DATE_FORMAT = new SimpleDateFormat("YYYY-mm-dd");

  public static class DateFormatThread implements Runnable {

    //DateFormat线程不安全
    @Override
    public void run() {
      System.out.println(DATE_FORMAT.format(new Date()));
    }
  }

  public static void main(String[] args) throws InterruptedException {
    for (int i = 0; i < 100000; i++) {
      Thread thread = new Thread(new DateFormatThread());
      thread.start();
      thread.join();
    }
  }
}
